package cn.live.kyle.questionnaire.question;

import org.w3c.dom.Element;

import cn.live.kyle.questionnaire.R;
import android.view.View;
import android.widget.TextView;

public class QuestionItem {
	protected Element mElement;
	protected QuestionPage mQuestionPage;
	protected View mQuestionItemView;
	protected boolean mIsAnswered;
	protected boolean mIsEmptyEnable;

	public QuestionItem(Element element, QuestionPage page) {
		mElement = element;
		mQuestionPage = page;
		mIsAnswered = false;
		mIsEmptyEnable = false;

		String emptyAttr = mElement.getAttribute(QuestionDomParser.ATTR_EMPTY);
		if (emptyAttr.equals(QuestionDomParser.ATTR_EMPTY_ENABLE)) {
			mIsEmptyEnable = true;
		}
	}

	public View getQuestionItemView() {
		return mQuestionItemView;
	}

	public boolean isAnswered() {
		return mIsEmptyEnable || mIsAnswered;
	}

	public void onFinish() {
	}

	public String getQuestionItemTitle() {
		return mElement.getAttribute(QuestionDomParser.ATTR_TITLE);
	}

	public void hideQuestionItemTiteView(boolean hide) {
		TextView titleView = (TextView) mQuestionItemView
				.findViewById(R.id.questionTitle);
		if (hide) {
			titleView.setVisibility(View.GONE);
		} else {
			titleView.setVisibility(View.VISIBLE);
		}
	}
}
